import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Layout from './components/Layout';
import AuthGuard from './components/AuthGuard';
import ToastContainer from './components/ToastContainer';
import ModalContainer from './components/ModalContainer';
import Login from './pages/Login';
import Dashboard from './pages/Dashboard';
import Accounts from './pages/Accounts';
import AIProviders from './pages/AIProviders';
import Avatars from './pages/Avatars';
import AvatarGroupDetail from './pages/AvatarGroupDetail';
import Videos from './pages/Videos';
import TextGeneration from './pages/TextGeneration';
import UserPersona from './pages/UserPersona';
import NotFound from './pages/NotFound';

function App() {
  return (
    <Router>
      <Routes>
        <Route path="/login" element={<Login />} />
        <Route
          path="/*"
          element={
            <AuthGuard>
              <Routes>
                <Route path="/" element={<Layout />}>
                  <Route index element={<Dashboard />} />
                  <Route path="accounts" element={<Accounts />} />
                  <Route path="ai-providers" element={<AIProviders />} />
                  <Route path="avatars" element={<Avatars />} />
                  <Route path="avatars/group/:groupId" element={<AvatarGroupDetail />} />
                  <Route path="videos" element={<Videos />} />
                  <Route path="text-generation" element={<TextGeneration />} />
                  <Route path="user-persona" element={<UserPersona />} />
                  {/* 404 Not Found Route */}
                  <Route path="*" element={<NotFound />} />
                </Route>
              </Routes>
            </AuthGuard>
          }
        />
      </Routes>

      {/* 全局组件 */}
      <ToastContainer />
      <ModalContainer />
    </Router>
  );
}

export default App;
